package com.salt.modules.sys.web;

import com.salt.common.json.AjaxJson;
import com.salt.modules.sys.service.VerifyService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description
 * @Author salt
 * @Date 2022/9/7
 * @Version 1.0.1
 */
@RestController
@AllArgsConstructor
@RequestMapping("sys/verify")
public class VerifyController {

    private final VerifyService verifyService;


    @PostMapping("validate")
    //@OperationRecord(service = "系统服务", module = "安全验证", operation = "短信验证", description = "短信验证")
    public AjaxJson validate(HttpServletRequest request,
                             @RequestParam("mobile") String mobile,
                             @RequestParam("smsType") String smsType) {
        return verifyService.validate(request, mobile, smsType);
    }

    @GetMapping("capture")
    //@OperationRecord(service = "系统服务", module = "安全验证", operation = "获取", description = "获取安全验证图片")
    public AjaxJson capture(@RequestParam("account") String account) {
        return verifyService.capture(account);
    }

    // 安全验证
    @GetMapping("check")
    //@OperationRecord(service = "系统服务", module = "安全验证", operation = "校验", description = "")
    public AjaxJson captureValidate(@RequestParam("captureId") String captureId,
                                    @RequestParam("location") Integer location,
                                    @RequestParam("account") String account){
        return verifyService.captureValidate(captureId, location, account);
    }
}
